<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <meta property="qc:admins" content="6525276424516367" />
    <meta property="wb:webmaster" content="ce8327d47982a584" />

    <title>慕图素材</title>

    <link rel="stylesheet" href="/static/lib/bootstrap/css/bootstrap.css">
    <link rel="stylesheet" href="/static/schema/default/css/base.css">
    <link rel="stylesheet" href="/static/css/main.css">
    <link href="/static/schema/default/css/dashboard.css" rel="stylesheet">

    <script src="/static/lib/jquery/jquery-2.1.3.min.js"></script>
    <script src="/static/lib/bootstrap/js/bootstrap.js"></script>
    <script type="text/javascript" src="/static/js/plupload/plupload.full.min.js"></script>
    <script type="text/javascript" src="/static/js/plupload/i18n/zh_CN.js"></script>
    <script type="text/javascript" src="/static/js/ui.js"></script>
    <script type="text/javascript" src="/static/js/qiniu.js"></script>

    <style type="text/css">
        .modal-body{

            height: 500px;
        }
        #himg {
            margin-left: 10px;
        }
    </style>
</head>
<body>
    <nav class="navbar navbar-inverse navbar-fixed-top">
        <div class="container-fluid">
            <div id="navbar" class="navbar-collapse collapse row">
                <div class="col-sm-offset-1">
                    <ul class="nav navbar-nav">
                        <li >
                            <a href="/">首页</a>
                        </li>
                        <li >
                            <a href="/auth/index">登录</a>
                        </li>
                        <li >
                            <a href="/auth/logout">退出</a>
                        </li>
                        <li >
                            <a href="/resource/upload/index">上传资源</a>
                        </li>
                         <li >
                            <a href="/resource/matter/create/index">创建素材</a>
                        </li>
                        <li >
                            <a href="/resource/matter/manage/index">素材管理</a>
                        </li>
                 
                        <li >
                            <a href="/resource/binder/manage/index">收藏夹管理</a>
                        </li>
                    </ul>
                </div>
            </div>
        </div>
    </nav>
    <div class="container-fluid">
        <div class="row">
            <div class="col-sm-6 col-sm-offset-2 alertDiv" id="notice_messages"></div>
        </div>
    </div>
    <div class="container-fluid">
        <div class="row">
            <div class="col-sm-11 col-sm-offset-1 main">
                <div clas="row">
                    <div class="col-sm-12 ">

                        <div class="row-fluid">
                            <h4 class="sub-title">
                                <Strong>上传资源</Strong>
                            </h4>
                        </div>
                        <form action="" method="post" id="sourceForm" class="form-horizontal" for="ala_ocr"enctype="multipart/form-data">
                            <div class="form-group">
                                <label class="control-label col-sm-2" for="comment">上传类型：</label>
                                <div class="controls col-sm-6">
                                    <label class="radio-inline">
                                        <input type="radio" name="sourceType" value="262145" checked="checked">灵感图</label>
                                    <label class="radio-inline">
                                        <input type="radio" name="sourceType" value="262146">psd源文件</label>
                                    <label class="radio-inline">
                                        <input type="radio" name="sourceType" value="262147">psd展示图</label>
                                    
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="control-label col-sm-2" for="comment">文件(支持多选)：</label>
                                <div class="controls col-sm-3" id="container">
                                    <a class="btn btn-default " id="sourcePikPic" href="#" > <i class="glyphicon glyphicon-plus"></i>
                                        <span>选择文件</span>
                                    </a>
                                    <a class="btn btn-default " id="sourcePikPsd" href="#"  style="display:none;"> <i class="glyphicon glyphicon-plus"></i>
                                        <span>选择文件2</span>
                                    </a>
                                    <a class="btn btn-default " id="sourcePikShow" href="#"  style="display:none;"> <i class="glyphicon glyphicon-plus"></i>
                                        <span>选择文件3</span>
                                    </a>
                                </div>
                            </div>

                        </form>
                        <div style="display:none" id="success" class="col-md-12">
                            <div class="alert-success">队列全部文件处理完毕</div>
                        </div>
                        <div class="col-md-12 ">
                            <table class="table table-striped table-hover text-left"   style="margin-top:40px;display:none">
                                <thead>
                                    <tr>
                                        <th class="col-md-4">Filename</th>
                                        <th class="col-md-2">Size</th>
                                        <th class="col-md-6">Detail</th>
                                    </tr>
                                </thead>
                                <tbody id="fsUploadProgress"></tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    

    <script type="text/javascript">
    

$(function() {
    function getDomain() {
        var flag = $("#sourceForm [name='sourceType']:checked").val();
        if (flag == "262146"){
            return "http://7xn9d1.com1.z0.glb.clouddn.com/"
        }
        return "http://7jpo6w.com1.z0.glb.clouddn.com/";
    }
    function getTokenUrl() {
        var flag = $("#sourceForm [name='sourceType']:checked").val();
        return "/resource/upload/token?flag="+ flag;
    }

    var q1 = new QiniuJsSDK();
    var q2 = new QiniuJsSDK();
    var q3 = new QiniuJsSDK();
    var uploader = q1.uploader({
        runtimes: 'html5,flash,html4',
        browse_button: 'sourcePikPic',
        container: 'container',
        drop_element: 'container',
        max_file_size: '1024mb',
        flash_swf_url: 'js/plupload/Moxie.swf',
        dragdrop: true,
        chunk_size: '1GB',
        uptoken_url: "/resource/upload/token?ispub=1",
        domain: "http://7jpo6w.com1.z0.glb.clouddn.com/",
        get_new_uptoken: true,
        // downtoken_url: '/downtoken',
        // unique_names: true,
        save_key: true,
        x_vars: {
    
            'flag': function(up, file) {
                return $("#sourceForm [name='sourceType']:checked").val();
            },
        },
        //         var time = (new Date()).getTime();
        //         // do something with 'time'
        //         return time;
        //     },
        // },
        auto_start: true,
        init: {
            'FilesAdded': function(up, files) {
                
                $('table').show();
                $('#success').hide();
                plupload.each(files, function(file) {
                    var progress = new FileProgress(file, 'fsUploadProgress');
                    progress.setStatus("等待...");
                    progress.bindUploadCancel(up);
                });
            },

            'BeforeUpload': function(up, file) {

                var progress = new FileProgress(file, 'fsUploadProgress');
                var chunk_size = plupload.parseSize(this.getOption('chunk_size'));
                if (up.runtime === 'html5' && chunk_size) {
                    progress.setChunkProgess(chunk_size);
                }
            },
            'UploadProgress': function(up, file) {
                var progress = new FileProgress(file, 'fsUploadProgress');
                var chunk_size = plupload.parseSize(this.getOption('chunk_size'));
                progress.setProgress(file.percent + "%", file.speed, chunk_size);
            },
            'UploadComplete': function() {
                $('#success').show();
            },
            'FileUploaded': function(up, file, info) {
                var progress = new FileProgress(file, 'fsUploadProgress');
                progress.setComplete(q1, up, info);
            },
            'Error': function(up, err, errTip) {
                $('table').show();
                var progress = new FileProgress(err.file, 'fsUploadProgress');
                progress.setError();
                progress.setStatus(errTip);
            }
                // ,
                // 'Key': function(up, file) {
                //     var key = "";
                //     // do something with key
                //     return key
                // }
        }
    }); 

   
    var uploaderPsd = q2.uploader({
        runtimes: 'html5,flash,html4',
        browse_button: 'sourcePikPsd',
        container: 'container',
        drop_element: 'container',
        max_file_size: '1024mb',
        flash_swf_url: 'js/plupload/Moxie.swf',
        dragdrop: true,
        chunk_size: '1GB',
        uptoken_url: "/resource/upload/token?ispub=0",
        domain: "http://7xn9d1.com1.z0.glb.clouddn.com/",
        get_new_uptoken: true,
        // downtoken_url: '/downtoken',
        // unique_names: true,
        save_key: true,
        x_vars: {
    
            'flag': function(up, file) {
                return $("#sourceForm [name='sourceType']:checked").val();
            },
        },
        //         var time = (new Date()).getTime();
        //         // do something with 'time'
        //         return time;
        //     },
        // },
        auto_start: true,
        init: {
            'FilesAdded': function(up, files) {
                
                $('table').show();
                $('#success').hide();
                plupload.each(files, function(file) {
                    var progress = new FileProgress(file, 'fsUploadProgress');
                    progress.setStatus("等待...");
                    progress.bindUploadCancel(up);
                });
            },

            'BeforeUpload': function(up, file) {

                var progress = new FileProgress(file, 'fsUploadProgress');
                var chunk_size = plupload.parseSize(this.getOption('chunk_size'));
                if (up.runtime === 'html5' && chunk_size) {
                    progress.setChunkProgess(chunk_size);
                }
            },
            'UploadProgress': function(up, file) {
                var progress = new FileProgress(file, 'fsUploadProgress');
                var chunk_size = plupload.parseSize(this.getOption('chunk_size'));
                progress.setProgress(file.percent + "%", file.speed, chunk_size);
            },
            'UploadComplete': function() {
                $('#success').show();
            },
            'FileUploaded': function(up, file, info) {
                var progress = new FileProgress(file, 'fsUploadProgress');
                progress.setComplete(q2, up, info);
            },
            'Error': function(up, err, errTip) {
                $('table').show();
                var progress = new FileProgress(err.file, 'fsUploadProgress');
                progress.setError();
                progress.setStatus(errTip);
            }
                // ,
                // 'Key': function(up, file) {
                //     var key = "";
                //     // do something with key
                //     return key
                // }
        }
    }); 

     var uploaderShow = q3.uploader({
        runtimes: 'html5,flash,html4',
        browse_button: 'sourcePikShow',
        container: 'container',
        drop_element: 'container',
        max_file_size: '1024mb',
        flash_swf_url: 'js/plupload/Moxie.swf',
        dragdrop: true,
        chunk_size: '1GB',
        uptoken_url: "/resource/upload/token?ispub=1",
        domain: "http://7jpo6w.com1.z0.glb.clouddn.com/",
        get_new_uptoken: true,
        // downtoken_url: '/downtoken',
        // unique_names: true,
        save_key: true,
        x_vars: {
    
            'flag': function(up, file) {
                return $("#sourceForm [name='sourceType']:checked").val();
            },
        },
        //         var time = (new Date()).getTime();
        //         // do something with 'time'
        //         return time;
        //     },
        // },
        auto_start: true,
        init: {
            'FilesAdded': function(up, files) {
                
                $('table').show();
                $('#success').hide();
                plupload.each(files, function(file) {
                    var progress = new FileProgress(file, 'fsUploadProgress');
                    progress.setStatus("等待...");
                    progress.bindUploadCancel(up);
                });
            },

            'BeforeUpload': function(up, file) {

                var progress = new FileProgress(file, 'fsUploadProgress');
                var chunk_size = plupload.parseSize(this.getOption('chunk_size'));
                if (up.runtime === 'html5' && chunk_size) {
                    progress.setChunkProgess(chunk_size);
                }
            },
            'UploadProgress': function(up, file) {
                var progress = new FileProgress(file, 'fsUploadProgress');
                var chunk_size = plupload.parseSize(this.getOption('chunk_size'));
                progress.setProgress(file.percent + "%", file.speed, chunk_size);
            },
            'UploadComplete': function() {
                $('#success').show();
            },
            'FileUploaded': function(up, file, info) {
                var progress = new FileProgress(file, 'fsUploadProgress');
                progress.setComplete(q3, up, info);
            },
            'Error': function(up, err, errTip) {
                $('table').show();
                var progress = new FileProgress(err.file, 'fsUploadProgress');
                progress.setError();
                progress.setStatus(errTip);
            }
                // ,
                // 'Key': function(up, file) {
                //     var key = "";
                //     // do something with key
                //     return key
                // }
        }
    }); 

    $("#sourceForm [name='sourceType']").bind('change', function(){
        var flag = $("#sourceForm [name='sourceType']:checked").val();
        if (flag == "262145"){
            $("#sourcePikPic").show();
            $("#sourcePikPsd").hide();
            $("#sourcePikShow").hide();
        }else if(flag == "262146"){
            $("#sourcePikPic").hide();
            $("#sourcePikPsd").show();
            $("#sourcePikShow").hide();
        }else{
            $("#sourcePikPic").hide();
            $("#sourcePikPsd").hide();
            $("#sourcePikShow").show();
        }
    });

   
    
     $('body').on('click', 'table button.btn', function() {
        $(this).parents('tr').next().toggle();
    });
     
        
});
</script>

</body>
</html>
